<?php
	include 'config.php';
	include 'functions.php';
	$lexid = $_SESSION['lexid'];
	$p1 = "";
	$p2 = "";
	$refStr = "";

	$formdata = $_POST['formData'];
	$last = end(array_keys($formdata));
	$next = next($formdata);
	$prev = prev($formdata);

	//echo count($formdata);

	foreach ($formdata as $key => $value) {
		$refStr .= trim($value) . " ";
	}

	$reflection = trim($refStr);
	$query = "INSERT INTO reflection (reflection, lexid) VALUES ('$reflection','$lexid')";
	$result = mysqli_query($con, $query) or die("Could not record reflection in database");
	header('LOCATION:contextmap.php'); //go to the next step of the form
?>
